#include "KetBra.hpp"

KetBra& KetBra::operator=(const KetBra& rhs) {
	row_ = rhs.getRow();
	col_ = rhs.getCol();
	amplitude_ = rhs.getAmplitude();
	return *this;
}

ElementaryOperatorP KetBra::matMul(
    const ElementaryOperator& right) const {
  return right.concreteMatMul(*this);
}

ElementaryOperatorP KetBra::concreteMatMul(const KetBra& left) const {
  KetBra* result(new KetBra());
  if (left.getCol() == this->getRow()) {
    result->setRow(left.getRow());
    result->setCol(this->getCol());
    result->setAmplitude(this->getAmplitude() * left.getAmplitude());
  } else {
    result->setAmplitude(0.0);
  }
  return ElementaryOperatorP(result);
}

ElementaryOperatorP KetBra::concreteMatMul(const IdentityOperator& left) const {
  ElementaryOperatorP result(new KetBra(*this));
  return result;
}

std::string KetBra::show() const {
	std::stringstream oss;
	oss << amplitude_ << "|" << row_ << "><" << col_ << "|";
	return oss.str();
}
